package com.example.shop.goods.dao;

import com.example.shop.goods.dto.ModifyGoodBaseInfoParam;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface ModifyGoodBaseInfoParamDao {

    @Update("<script>" +
            "update goods " +
            "set " +
            "<if test='modifyInfo.goodsType != null'>" +
                "goods_type = #{modifyInfo.goodsType}," +
            "</if>" +
            "<if test='modifyInfo.goodsName != null'>" +
                "goods_name = #{modifyInfo.goodsName}," +
            "</if>" +
            "<if test='modifyInfo.goodsIntroduction != null'>" +
                "goods_introduction = #{modifyInfo.goodsIntroduction}," +
            "</if>" +
            "goods_id = goods_id " +
            "where merchant_id = ${merchantId} and goods_id = ${modifyInfo.goodsId}" +
            "</script>")
    int updateNotNull(@Param("merchantId")long merchantId,@Param("modifyInfo") ModifyGoodBaseInfoParam modifyInfo);
}
